package cn.tedu.appointment.accounts.controller;

import cn.tedu.appointment.accounts.pojo.dto.StaffLoginParam;
import cn.tedu.appointment.accounts.pojo.dto.StaffSearchParam;
import cn.tedu.appointment.accounts.pojo.vo.StaffVO;
import cn.tedu.appointment.accounts.service.StaffService;
import cn.tedu.appointment.base.response.JsonResult;
import cn.tedu.appointment.base.response.StatusCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Api(tags = "员工模块")
@RestController
@RequestMapping("/v1/staff/")
public class StaffController {

    @Autowired
    StaffService staffService;

    @ApiOperation(value = "员工登录")
    @PostMapping("login")
    public JsonResult login(@RequestBody StaffLoginParam staffLoginParam){
        log.debug("员工登录:staffLoginParam={}",staffLoginParam);
        StaffVO staffVO = staffService.login(staffLoginParam);
        return JsonResult.ok(staffVO);
    }

    @ApiOperation(value = "搜索员工")
    @PostMapping("searchStaff")
    public JsonResult searchStaff(StaffSearchParam staffSearchParam){
        log.debug("搜索员工:staffLoginParam={}",staffSearchParam);
        List<StaffVO> staffVOList = staffService.searchStaff(staffSearchParam);
        return JsonResult.ok(staffVOList);
    }

    @ApiOperation(value = "手机号验证码")
    @GetMapping("getVerify")
    public JsonResult getVerify(){
        String  verify = staffService.getVerify();
        return JsonResult.ok(verify);
    }

}
